package org.jeecg.activiti.ActivitClass;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;
import org.jeecg.modules.product.entity.Product;
import org.jeecg.modules.product.mapper.ProductMapper;

public class ProductSetting implements JavaDelegate {
    @Override
    public void execute(DelegateExecution execution){
//        log.info("设置产品基础信息流程变量");
        String productId = String.valueOf(execution.getVariable("product_id"));
        QueryWrapper<Product> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("product_id", productId);
        ProductMapper productMapper = SpringContextHolder.getBean(ProductMapper.class);
        Product product = productMapper.selectOne(queryWrapper);
        execution.setVariable("purchase_limit", product.getPurchaseLimit());
    }
}
